home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / misc / gms_dev.lha / GMS / Source / Asm / Blitter / DrawPixel.s < prev    next >
Encoding:
Text File  |  1997-07-08  |  3.0 KB  |  130 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Name:      Draw Pixel
  3. ;Author:    Paul Manias
  4. ;Copyright: DreamWorld Productions (c) 1996-1997.  Freely distributable.
  5. ;
  6. ;Draws a pixel on a screen without destroying the background.
  7.  
  8.     INCDIR    "INCLUDES:"
  9.     INCLUDE    "games/games_lib.i"
  10.     INCLUDE    "games/games.i"
  11.  
  12.     SECTION    "DrawPixel",CODE
  13.  
  14. ;===========================================================================;
  15. ;                             INITIALISE DEMO
  16. ;===========================================================================;
  17.  
  18.     STARTGMS
  19.  
  20. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  21.     move.l    GMSBase(pc),a6    ;Activate user preferences.
  22.     CALL    AllocBlitter    ;Allocate the blitter.
  23.     tst.l    d0
  24.     bne    .Error_Blitter
  25.  
  26.     lea    FILE_Background(pc),a1    ;Load the picture.
  27.     moveq    #GETPALETTE|VIDEOMEM,d0
  28.     CALL    LoadPicFile
  29.     move.l    d0,PIC_Background
  30.     beq.s    .Error_Picture
  31.  
  32.     CALL    GetScreen
  33.     move.l    d0,Screen
  34.     beq.s    .Error_Screen
  35.     move.l    d0,a0
  36.     move.l    PIC_Background(pc),a1
  37.     move.w    #320,GS_ScrWidth(a0)
  38.     move.w    #256,GS_ScrHeight(a0)
  39.     move.l    PIC_AmtColours(a1),GS_AmtColours(a0)
  40.     move.w    PIC_Planes(a1),GS_Planes(a0)
  41.     move.w    PIC_Width(a1),GS_PicWidth(a0)
  42.     move.w    PIC_Height(a1),GS_PicHeight(a0)
  43.     move.l    PIC_Palette(a1),GS_Palette(a0)
  44.     move.l    PIC_Data(a1),GS_MemPtr1(a0)
  45.     move.w    PIC_ScrMode(a1),GS_ScrMode(a0)
  46.     move.w    PIC_ScrType(a1),GS_ScrType(a0)
  47.     CALL    AddScreen
  48.     tst.l    d0
  49.     beq.s    .Error_Screen
  50.  
  51.     CALL    ShowScreen
  52.  
  53.     CALL    InitJoyPorts
  54.  
  55.     bsr.s    Main
  56.  
  57. .ReturnToDOS
  58.     move.l    GMSBase(pc),a6
  59.     move.l    Screen(pc),a0
  60.     CALL    DeleteScreen
  61. .Error_Screen
  62.     move.l    PIC_Background(pc),a1
  63.     CALL    FreePic
  64. .Error_Picture
  65.     CALL    FreeBlitter
  66. .Error_Blitter
  67.     MOVEM.L    (SP)+,A0-A6/D1-D7
  68.     moveq    #ERR_OK,d0
  69.     rts
  70.  
  71. ;===========================================================================;
  72. ;                                MAIN LOOP
  73. ;===========================================================================;
  74.  
  75. Main:    move.l    GMSBase(pc),a6
  76.  
  77.     moveq    #100,d6
  78.     moveq    #100,d7
  79.  
  80. .loop    move.l    Screen(pc),a0
  81.     move.l    GS_Bitmap(a0),a0
  82.     movem.w    OldPixel(pc),d1/d2/d3
  83.     tst.w    d3
  84.     blt.s    .read
  85.     CALL    DrawPixel    ;>> = Draw the old background pixel.
  86.  
  87. .read    move.l    Screen(pc),a0
  88.     move.l    GS_Bitmap(a0),a0
  89.     move.w    d6,d1    ;d1 = X Coordinate.
  90.     move.w    d7,d2    ;d2 = Y Coordinate.
  91.     CALL    ReadPixel    ;>> = Read the pixel.
  92.     movem.w    d6/d7,OldPixel    ;MA = Save coords of next pixel.
  93.     move.w    d0,OldPixel+4    ;MA = Save colour of next pixel.
  94.  
  95.     move.l    Screen(pc),a0
  96.     move.l    GS_Bitmap(a0),a0
  97.     move.w    #3,d3    ;d3 = Colour.
  98.     CALL    DrawPixel    ;>> = Draw our pixel.
  99.  
  100.     CALL    WaitVBL    ;>> = Wait for VBL.
  101.  
  102.     moveq    #JPORT1,d0    ;Read the mouse, then update the
  103.     moveq    #JT_ZBXY,d1    ;BOB's X and Y co-ordinates.
  104.     CALL    ReadJoyPort
  105.     move.w    d0,d1
  106.     ext.w    d0
  107.     asr.w    #8,d1
  108.     add.w    d0,d7
  109.     add.w    d1,d6
  110.     btst    #MB_LMB,d0
  111.     beq.s    .loop
  112.     rts
  113.  
  114. OldPixel:
  115.     dc.w    0,0,-1
  116.  
  117. ;===========================================================================;
  118. ;                                  DATA
  119. ;===========================================================================;
  120.  
  121. Screen:    dc.l    0
  122.  
  123. PIC_Background:
  124.     dc.l    0
  125.  
  126. FILE_Background:
  127.     dc.b    "GMS:demos/data/PIC.Green",0
  128.     even
  129.  
  130.